﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

using System.Data;

using CooWork.Models;
using Coowork.Data.Mapping;

namespace CooWork.Services
{
    public class TaskActionLog:ITaskActionLog
    {
        public void LogAction(string msg,int taskId,int? clogId)
        {
            if (!string.IsNullOrWhiteSpace(msg))
            {
                CooWorkEntities context = new CooWorkEntities();
                CooTaskLog ctl = new CooTaskLog();
                ctl.cid = UserService.UcId();
                ctl.clogId = clogId;
                ctl.LogDate = DateTime.Now;
                ctl.Msg = msg;
                ctl.UserId = UserService.Ugid();
                ctl.taskId = taskId;

                context.CooTaskLogs.Add(ctl);
                context.SaveChanges();
            }
        }


        public void LogAction(string msg, int taskId, int? clogId,int cid,Guid guid)
        {
            if (!string.IsNullOrWhiteSpace(msg))
            {
                CooWorkEntities context = new CooWorkEntities();
                CooTaskLog ctl = new CooTaskLog();
                ctl.cid = cid;
                ctl.clogId = clogId;
                ctl.LogDate = DateTime.Now;
                ctl.Msg = msg;
                ctl.UserId = guid;
                ctl.taskId = taskId;

                context.CooTaskLogs.Add(ctl);
                context.SaveChanges();
            }
        }

    }
}